package com.dingding.message;

import java.math.BigDecimal;
import java.util.Calendar;

/**
* @ClassName: MessageModel 
* @Description: 叮叮搭车短信模板
* @author yhq 
* @date 2015-10-27 下午02:54:45
 */
public class MessageModel {

	/*-------------------------发给所有用户消息模块开始------------------------------*/
	/**
	 * @Title: registered 
	 * @Description: 注册验证码的短信模板
	 * @param validateNumber 注册验证码
	 * @return String    返回类型 
	 * @throws
	 */
	public static String registered(String validateNumber) {

		// 创建拼接注册验证码的对象
		StringBuilder registered = new StringBuilder();

		registered.append("您登录的验证码为");
		registered.append(validateNumber);
		registered.append("，请输入后进行验证，有效时间10分钟，谢谢使用！");

		return registered.toString();
	}

	/**
	 * @Title: backPwd 
	 * @Description: 找回密码的短信模板
	 * @param validateNumber 验证码
	 * @return String    返回类型 
	 * @throws
	 */
	public static String backPwd(String validateNumber) {

		// 创建拼接注册验证码的对象
		StringBuilder registered = new StringBuilder();

		registered.append("您首次提现登录的验证码为");
		registered.append(validateNumber);
		registered.append("，请输入后进行验证，有效时间10分钟，谢谢使用！");

		return registered.toString();
	}

	/**
	 * @Title: withdrawals 
	 * @Description: 提现的短信模板
	 * @param currencyNumber 叮币数量
	 * @return String    返回类型 
	 * @throws
	 */
	public static String withdrawals(Integer currencyNumber) {

		// 创建拼接提现短信的对象
		StringBuilder withdrawals = new StringBuilder();

		withdrawals.append("您");
		withdrawals.append(getDateStr());
		withdrawals.append("申请提现" + currencyNumber);
		withdrawals.append("叮币，审核成功后5-7个工作日内将会到账，如有疑问请拨打客服电话 010-5976-7214");

		return withdrawals.toString();
	}

	/**
	 * @Title: resetPassword 
	 * @Description:  重置密码成功，发送短信
	 * @return String    返回类型 
	 * @throws
	 */
	public static String resetPassword() {

		// 创建拼接重置密码成功的对象
		StringBuilder resetPassword = new StringBuilder();

		resetPassword.append("您");
		resetPassword.append(getDateStr());
		resetPassword.append("重置了登录密码，如有疑问请拨打客服电话 010-5976-7214");

		return resetPassword.toString();
	}

	/*-------------------------发给所有用户消息模块开始------------------------------*/

	/*-----------------发送给乘客开始-------------------*/
	/**
	 * 车主抢单
	 */
	public static final String DRIVER_GRAB_ORDER = "您的订单已被车主接单，请尽快支付后与车主联系，祝您搭车愉快!";
	/*-----------------发送给乘客结束-------------------*/

	/*-----------------发送给司机开始--------------------*/
	/**
	 * 乘客抢单
	 */
	public static final String PASSENGER_GRAB_ORDER = "您的订单已被乘客接单，等乘客支付后请您准时接乘!";

	/**
	 * 车主认证未通过
	 */
	public static final String DRIVER_AUTHENTICATION_NOT_THROUGH = "您提交的车主认证材料审核未通过，请修改后再次申请，感谢您的配合!";

	/**
	 * 车主认证通过
	 */
	public static final String DRIVER_AUTHENTICATION_THROUGH = "恭喜您成为认证车主，马上开启愉快的搭乘之旅吧!";

	/**
	 * 自动确认到达
	 */
	public static final String AUTO_CONFIRM_ARRIVAL = "您的订单已超时未确认到达，订单自动完成，车费将付给车主，感谢您此次搭乘";

	/**
	 * 乘客支付成功，给司机发送短信
	 */
	public static String passengerPaySuccess(String passengerName) {

		// 创建乘客支付完成给司机发送短信的模板
		StringBuilder passengerPay = new StringBuilder();

		passengerPay.append("乘客" + passengerName);
		passengerPay.append("已完成支付，订单完成后车费将转到您的钱包中，请务必准时接乘。");

		return passengerPay.toString();
	}

	/**
	 * @Title: confirmArrive 
	 * @Description: 乘客确认到达
	 * @param passengerName 乘客姓名
	 * @return String    返回类型 
	 * @throws
	 */
	public static String confirmArrive(String passengerName, BigDecimal integral) {

		// 创建乘客确认到达完成给司机发送短信的模板
		StringBuilder confirmArrive = new StringBuilder();

		confirmArrive.append("乘客" + passengerName);
		confirmArrive.append("已确认到达，车费");
		if (integral.compareTo(new BigDecimal(0)) != 0) {
			confirmArrive.append("及赠送的");
			confirmArrive.append(integral);
			confirmArrive.append("积分");
		}
		confirmArrive.append("将转入您的钱包，感谢您的接乘!");

		return confirmArrive.toString();
	}

	/**
	 * @Title: cancelOrder 
	 * @Description: 取消订单
	 * @param passengerName 乘客姓名
	 * @param cancelReason 取消原因
	 * @return String    返回类型 
	 * @throws
	 */
	public static String cancelOrder(String passengerName, String cancelReason) {

		// 创建乘客确认到达完成给司机发送短信的模板
		StringBuilder cancelOrder = new StringBuilder();

		cancelOrder.append("乘客" + passengerName);
		cancelOrder.append(getDateStr());
		cancelOrder.append("取消订单。取消理由为：" + cancelReason);

		return cancelOrder.toString();
	}

	/**
	 * @Title: cancelOrder 
	 * @Description: 取消订单
	 * @param passengerName 乘客姓名
	 * @param cancelReason 取消原因
	 * @param integral 赠送积分
	 * @return String    返回类型 
	 * @throws
	 */
	public static String autoCancelOrder(String name, double integral) {

		// 创建乘客确认到达完成给司机发送短信的模板
		StringBuilder cancelOrder = new StringBuilder();

		cancelOrder.append(name + "先生/女士，很抱歉的通知您，您于");
		cancelOrder.append(getDateStr());
		cancelOrder.append("发布的订单因超时已取消");
		if(integral != 0){
			cancelOrder.append(",赠予您的");
			cancelOrder.append(integral);
			cancelOrder.append("积分稍后会转到您的账户中");
		}
		cancelOrder.append("，感谢您的支持！");
		
		return cancelOrder.toString();
	}

	/**
	 * @Title: beOverdue 
	 * @Description: 车主驾驶证过期
	 * @param driverName 司机姓名
	 * @return String    返回类型 
	 * @throws
	 */
	public static String beOverdue(String driverName) {

		// 创建司机驾驶证过期发送短信的模板
		StringBuilder beOverdue = new StringBuilder();

		beOverdue.append("车主" + driverName);
		beOverdue.append("您好，您的驾驶证有效日期即将到期，请将新证件及时上传并申请认证。");

		return beOverdue.toString();
	}
	/*-----------------发送给司机结束--------------------*/

	/*-----公共模块开始-------*/

	// 获取一个拼接时间的字符串
	public static String getDateStr() {

		// 创建时间对象
		Calendar now = Calendar.getInstance();

		// 创建时间拼接字符串的对象
		StringBuilder dateStr = new StringBuilder();

		String month = null;
		String day = null;
		String hour = null;
		String minute = null;
		String sencond = null;

		if (now.get(Calendar.MONTH) + 1 < 10) {
			month = "0" + (now.get(Calendar.MONTH) + 1);
		} else {
			month = "" + (now.get(Calendar.MONTH) + 1);
		}

		if (now.get(Calendar.DAY_OF_MONTH) < 10) {
			day = "0" + now.get(Calendar.DAY_OF_MONTH);
		} else {
			day = "" + now.get(Calendar.DAY_OF_MONTH);
		}

		if (now.get(Calendar.HOUR_OF_DAY) < 10) {
			hour = "0" + now.get(Calendar.HOUR_OF_DAY);
		} else {
			hour = "" + now.get(Calendar.HOUR_OF_DAY);
		}

		if (now.get(Calendar.MINUTE) < 10) {
			minute = "0" + now.get(Calendar.MINUTE);
		} else {
			minute = "" + now.get(Calendar.MINUTE);
		}

		if (now.get(Calendar.SECOND) < 10) {
			sencond = "0" + now.get(Calendar.SECOND);
		} else {
			sencond = "" + now.get(Calendar.SECOND);
		}

		dateStr.append("已于");
		dateStr.append(now.get(Calendar.YEAR) + "年");
		dateStr.append(month + "月");
		dateStr.append(day + "日 ");
		dateStr.append(hour + ":");
		dateStr.append(minute + ":");
		dateStr.append(sencond + " ");

		return dateStr.toString();
	}
	/*-----公共模块结束-------*/

}
